import Vue from 'vue'
import Vuex from 'vuex'
import {getAlbumList, getArtistList, getMusicList} from "@/api/common";

Vue.use(Vuex)

const store = new Vuex.Store({

    modules: {
        // 用户
        user: {
            namespaced: true,
            state: {},
            mutations: {}
        },
        //音乐
        music:{
            namespaced:true,
            state:{
                musicData:[],
                data:{
                    page: "1",
                    size: "200",
                    orders: [
                        {
                            column: "1",
                            asc: true
                        }
                    ],
                    name: "",
                    albumName: "",
                    artistName: "",
                    offset: 0
                }
            },
            mutations:{
                reqMusicList(state){
                    getMusicList(state.data).then(resp=>{
                        state.musicData=resp.data.data.records
                    })
                }
            },
        },
        // 专辑
        album:{
            namespaced:true,
            state:{
                albumData:[],
                data:{
                    page: "1",
                    size: 200,
                    orders: [
                        {
                            column: "1",
                            asc: true
                        }
                    ],
                    name: "",
                    description: "",
                    offset: 0
                }
            },
            mutations:{
                reqAlbumList(state){
                    getAlbumList(state.data).then(resp => {
                        // console.log("艺术家：",resp.data.data.records)
                        state.albumData=resp.data.data.records
                    })
                }
            },
        },
        // 艺术家
        artist:{
            namespaced:true,
            state:{
                artistData:[],
                data:{
                    page: "1",
                    size: "100",
                    orders: [
                        {
                            column: "1",
                            asc: true
                        }
                    ],
                    name: "",
                    description: "",
                    offset: 0
                }
            },
            mutations:{
                reqArtisList(state){
                    getArtistList(state.data).then(resp => {
                        // console.log("艺术家",resp.data.data.records)
                        state.artistData=resp.data.data.records
                    })
                }
            },
        }
    },

})

export default store
